<?php

namespace Database\Factories;

use App\Models\ESCluster;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

class TaskFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
            'name' => 'cloud-detect' . date('-YmdHis'),
            'filepath' => config('task.path', '/home/workspace/') . 'public/csvs/' 
                            . date('YmdHis_') . substr(microtime(), 2,6) . '.csv',
            'estimate'=> $this->faker->randomElement([60, 120, 180]),
            'dev_id' => $this->faker->randomElement(ESCluster::all()->pluck('id')),
            'dev_type' => 'App\Models\ESCluster', 
            'status' => $this->faker->randomElement(['成功', '失败', '运行中']),
            'status_info' => '运行详情',
            'user_id' => $this->faker->randomElement(User::all()->pluck('id')),
            'remarks' => '备注',
        ];
    }
}
